﻿using System.Collections.Generic;
using System.IO;

namespace Red.Scripts.Project.Generator
{
    public class FileEnumerator
    {
        private List< string > _files = new List<string>();

        public ICollection<string> Extensions { get; private set; } = new List<string>();
        public IEnumerable<string> Files => _files;

        public void Enumerate( string path )
        {
            DirectoryInfo dir = new DirectoryInfo( path );

            IEnumerable< FileInfo > files = dir.EnumerateFiles( "*", SearchOption.AllDirectories );

            foreach( FileInfo fileInfo in files )
            {
                foreach ( string extension in Extensions )
                {
                    if ( fileInfo.Name.EndsWith( extension ) )
                    {
                        _files.Add( fileInfo.FullName );
                        break;
                    }
                }
            }
        }
    }
}
